import csv


def person_operate(csv_file):
    from u8_person import Person
    person = Person()
    with open(csv_file) as in_file:
        f_csv = csv.reader(in_file)
        tick = 0
        for row in f_csv:
            tick += 1
            cSBVCode = row[0]
            cSOCode = row[1]
            cDLCode = row[2]
            cPersonCode = row[3]
            person.update_saleBillVouch(cPersonCode, cSBVCode)
            person.update_saleOrder(cPersonCode, cSOCode)
            person.update_dispatchList(cPersonCode, cDLCode)
    print(f'操作完成，已处理{tick}项')


def department_operate(csv_file):
    from u8_department import Department
    department = Department()
    with open(csv_file) as in_file:
        f_csv = csv.reader(in_file)
        tick = 0
        for row in f_csv:
            tick += 1
            cSBVCode = row[0]
            cSOCode = row[1]
            cDLCode = row[2]
            cDepCode = row[3]
            department.update_saleBillVouch(cDepCode, cSBVCode)
            department.update_saleOrder(cDepCode, cSOCode)
            department.update_dispatchList(cDepCode, cDLCode)
    print(f'操作完成，已处理{tick}项')
